﻿Imports extranet.BC
Imports extranet.BE
Imports MetodosComuns
Imports System.Collections.Generic

Partial Class ranking_AdmRnkMediarMensagens
    Inherits System.Web.UI.Page

    Protected Sub grvRankings_RowEditing(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewEditEventArgs) Handles grvMensagens.RowEditing
        Response.Redirect("AdmRnkAnalisarMensagem.aspx?Id=" & grvMensagens.DataKeys(e.NewEditIndex).Value.ToString())
    End Sub

    Protected Sub btnVoltar_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnVoltar.Click

    End Sub

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

        '==================       PROCEDIMENTO  PADRÃO  SEGURANÇA     =============================
        Dim objBESeguranca As BESeguranca
        Dim objBEUsuario As BEUsuario = Session("objBEUsuario")
        If IsNothing(objBEUsuario) Then Response.Redirect(TELA_LOGOUT)
        Session("strTela") = MetodosComuns.GetCurrentPageName()
        If Not IsPostBack Then          ' SEGURANÇA
            objBESeguranca = BCSeguranca.SelecionaPermissoes(objBEUsuario.GrupoAcesso, Session("strTela"))
            If Not objBESeguranca.Autorizado Then Response.Redirect(TELA_LOGOUT)
            Session("objBESeguranca") = objBESeguranca
        Else
            objBESeguranca = Session("objBESeguranca")
        End If

        If Not IsPostBack Then
            Dim lstBEMensagens As New List(Of BEMensagem)
            Dim lstBERankings As List(Of BERanking) = BCRanking.ListarRanking(True)

            For Each objBERanking As BERanking In lstBERankings
                lstBEMensagens.AddRange(BCRanking.ListarMensagens(objBERanking.IdRanking))
            Next
            grvMensagens.DataSource = lstBEMensagens
            grvMensagens.DataBind()
        End If
    End Sub
End Class
